/*
 *  POJ2533: Longest Ordered Subsequence
 */

/*-------- Includes --------*/
#include <iostream>
#include <algorithm>

using namespace std;

/*-------- Defines --------*/


/*-------- Types --------*/


/*-------- Global Variables --------*/
int N;
int a[1000];
int d[1000];

/*-------- Function Prototypes --------*/


/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    cin >> N;

    for (int i = 0; i < N; i++) cin >> a[i];

    for (int i = 0; i < N; i++) d[i] = 1;

    // dynamic programming
    for (int i = 1; i < N; i++)
        for (int j = i - 1; j >= 0; j--)
            if (a[i] > a[j])
                d[i] = max(d[i], d[j] + 1);

    cout << *max_element(d, d + N) << endl;
}

/*-------- Functions --------*/

